Skip to content

Conversation

@MritunjayTiwari14
Copy link
Contributor

Fixes #1981.

@chrisbobbe
Copy link
Collaborator

Let's make a new enum value unknown instead of using google.

@MritunjayTiwari14
Copy link
Contributor Author

Thank you @chrisbobbe for the review, introduced a new enum value unknown to which all the unknow Emojiset are directed to.

Copy link
Collaborator

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Small comments below.

'presence_enabled': true,
});

// Verify unknown emojiset defaults to Emojiset.unknow
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Emojiset.unknown

Comment on lines 69 to 74
final settings = UserSettings.fromJson({
'twenty_four_hour_time': true,
'display_emoji_reaction_users': true,
'emojiset': unknownValue,
'presence_enabled': true,
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This .fromJson call will fail and need to be debugged each time we add a field to UserSettings.

Can you add a userSettings helper function in test/example_data.dart, on the pattern of similar helpers (like streamMessage or initialSnapshot), then I think this can just be

Suggested change
final settings = UserSettings.fromJson({
'twenty_four_hour_time': true,
'display_emoji_reaction_users': true,
'emojiset': unknownValue,
'presence_enabled': true,
});
final json = eg.userSettings().toJson()..['emojiset'] = unknownValue;
final settings = UserSettings.fromJson(json);

@MritunjayTiwari14 MritunjayTiwari14 force-pushed the issue_1981 branch 2 times, most recently from 1896109 to 59cd993 Compare November 12, 2025 06:21
@MritunjayTiwari14
Copy link
Contributor Author

Thank you @chrisbobbe for the Suggestion, have pushed the changes. PTAL.

Copy link
Collaborator

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just small comments below.

Also something I just noticed on this round: for the commit-message summary line, let's say

api: Accept unknown "emojiset" values in initial snapshot

return UserSettings(
twentyFourHourTime: twentyFourHourTime ?? TwentyFourHourTimeMode.twentyFourHour,
displayEmojiReactionUsers: displayEmojiReactionUsers ?? true,
emojiset: emojiset ?? Emojiset.unknown ,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should aim to make the defaults boring and representative of real data, and I think Emojiset.google would be better for that than Emojiset.unknown.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this helper can deduplicate some code in the initialSnapshot helper just below this.

Just below the userSettings function declaration, you can say

const _userSettings = userSettings;

then in initialSnapshot in choosing arguments for the InitialSnapshot constructor, you can say:

    userSettings: userSettings ?? _userSettings(),

@gnprice gnprice added the maintainer review PR ready for review by Zulip maintainers label Nov 13, 2025
@MritunjayTiwari14
Copy link
Contributor Author

Thank you @chrisbobbe for noticing that, I've also changed the value of TwentyFourHourTimeMode.twentyFourHour to default boring i.e TwentyFourHourTimeMode.twelveHour.

@MritunjayTiwari14 MritunjayTiwari14 changed the title initial_snapshot: Accept unknown "emojiset" values api: Accept unknown "emojiset" values in initial snapshot Nov 15, 2025
Copy link
Collaborator

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! One nit below, and I'll mark this for Greg's review.

Comment on lines 1319 to 1320
}

const _userSettings = userSettings;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove blank line above const _userSettings = userSettings;, following the pattern of other helpers in this file

@chrisbobbe chrisbobbe requested a review from gnprice November 18, 2025 23:43
@chrisbobbe chrisbobbe added integration review Added by maintainers when PR may be ready for integration and removed maintainer review PR ready for review by Zulip maintainers labels Nov 18, 2025
@MritunjayTiwari14
Copy link
Contributor Author

Thank you @chrisbobbe for the review, the new changes had been pushed. PTAL @gnprice.

Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @MritunjayTiwari14 for taking care of this, and thanks @chrisbobbe for the previous reviews! A few comments below.

Comment on lines +298 to 299
@JsonKey(unknownEnumValue: Emojiset.unknown)
Emojiset emojiset;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at other references to Emojiset to see if we might need this elsewhere.

One is in events:

      case UserSettingName.emojiset:
        return Emojiset.fromRawString(value as String);

It looks like the effect of that is that if the user's value for this setting gets changed to an unknown value, we'd still throw. Let's fix that so that it produces Emojiset.unknown, just like if the same unknown value is found in the initial snapshot.

Comment on lines +72 to +74

// Verify unknown emojiset defaults to Emojiset.unknown
check(settings.emojiset).equals(Emojiset.unknown);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment doesn't add anything that isn't said equally clearly by the code. So best to leave it out:

Suggested change
// Verify unknown emojiset defaults to Emojiset.unknown
check(settings.emojiset).equals(Emojiset.unknown);
check(settings.emojiset).equals(Emojiset.unknown);

Comment on lines +67 to +69
test('UserSettings.emojiset handles various unknown values', () {
final unknownValues = ['apple', 'microsoft', 'facebook', ''];
for (final unknownValue in unknownValues) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the first of these, there's no useful information expressed by checking the next two — it's hard to imagine what sort of possible bug could be introduced in the future that would hit when the value were "microsoft" but not when it's "apple". So simplify the story by leaving them out:

Suggested change
test('UserSettings.emojiset handles various unknown values', () {
final unknownValues = ['apple', 'microsoft', 'facebook', ''];
for (final unknownValue in unknownValues) {
test('UserSettings.emojiset handles various unknown values', () {
final unknownValues = ['apple', ''];
for (final unknownValue in unknownValues) {

(OTOH the empty string does add information, since that's an edge case where it's more conceivable that there could be a bug specifically affecting that case.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration review Added by maintainers when PR may be ready for integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accept unknown "emojiset" values

3 participants